package cn.qihua.service.impl;

import java.util.List;

import cn.qihua.dao.ISysOrganizationDAO;
import cn.qihua.model.SysOrganization;
import cn.qihua.service.IOrganizationService;

public class OrganizationService implements IOrganizationService {
	private ISysOrganizationDAO sysOrganizationDAO;

	
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.ISysOrganizationService#findById(java.lang.Integer)
	 */
	@Override
	public SysOrganization findById(Integer id) {
		return sysOrganizationDAO.findById(id);
	}
	
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.ISysOrganizationService#findByParentId(java.lang.Integer)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<SysOrganization> findByParentId(Integer parentId) {
		return sysOrganizationDAO.findByParentId(parentId);
	}

	
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.ISysOrganizationService#add(cn.qihua.model.SysOrganization)
	 */
	@Override
	public void add(SysOrganization transientInstance) {
		sysOrganizationDAO.save(transientInstance);
	}
	
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.ISysOrganizationService#del(java.lang.Integer)
	 */
	@Override
	public boolean del(Integer id) {
		SysOrganization SysOrganization = sysOrganizationDAO.findById(id);
		if (SysOrganization != null) {
			sysOrganizationDAO.delete(SysOrganization);
			return true;
		} else {
			return false;
		}
	}
	
	/* (non-Javadoc)
	 * @see cn.qihua.service.impl.ISysOrganizationService#findAll()
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<SysOrganization> findAll() {
		return sysOrganizationDAO.findAll();
	}

	public void setSysOrganizationDAO(ISysOrganizationDAO sysOrganizationDAO) {
		this.sysOrganizationDAO = sysOrganizationDAO;
	}
}
